home *** CD-ROM | disk | FTP | other *** search
- :Batutil c(o) 1990 Barry Simon and Richard Wilson
- : Version 1.0
- echo off
- if exist batutil.exe goto buOK
- echo This demo file requires BATUTIL.EXE to be in the default drive and directory
- goto end
- :echo1
- Welcome to the @1FBATUTIL@1E user input demo
- This demonstration will show how BATUTIL can get
- information from the user.
-
- :echo2
-
- I would like to save your environment to env.tmp and
- later restore it but that file exists
- May I erase it (Y/N)?
-
- :echo3
-
- The first way to get information is the GETKEY command. We'll try
- @1FBATUTIL {GE y n}
- and you'll need to reply with one key or the other. Your choice will get
- echoed on the screen; it can get returned in the errorlevel or the
- environmental variable RC. Now
-
- Please hit Y or N :
- :echo4
-
- GETKEY is case insensitive and flushes the keyboard buffer before looking
- for a response but you can change that or change whether there is a visible
- echo. You can specify that a wrong choice get beeped or that a choice not on
- the list just returns a special errorlevel. You can have BATUTIL exit with
- errorlevel 0 if there is no response in a specified time. You can even
- have the time shown in a ticking clock on screen. We'll show you the
- effect of
- @1FBATUTIL {EC You have $$L seconds left}{GE WA12 EL}
- after you hit any key.
-
-
- :echo5
-
-
- BATUTIL will also pop up a menu for you to choose from with the choice
- returned in the errorlevel. The file menudemo.bat illustrates this or, if
- you are running this as a choice from the main demo program, just choose
- the MENU DEMONSTRATION from the main menu.
-
- You can test for whether the CAPSLOCK key is pressed and branch on that; this
- is ideal for making a choice at the start of a long batch file and then
- leaving the room.
- @1FBATUTIL {QL C -}
- will return errorlevel 1 if on and 0 if off and turn it off if on.
-
- Please hit CAPSLOCK and then another key to continue.
-
-
- :echo6
- The errorlevel return was $x(RC).
-
- BATUTIL will also allow you to place strings in the environment. First we'll
- ask you to input a string and then to choose a filename from BATUTIL's file
- picker. Be sure to hit F1 when the file list is up to see what can be done.
- Now hit a key to continue.
-
-
- :echo7
-
-
- The string you entered was
- $S $x(foo)
- and the filename was
- $S $x(foo1)
- with a path of $x(FDIR)
-
- Thanks for using BATUTIL. Hit a key to exit.
-
- :buOK
- set cur=off
- BATUTIL {CU -}{CLS}{RO 2}{CO 1}{FP %0 echo1}
- if x%1==xfrommain goto frommain
- if not exist env.tmp goto efileOK
- BATUTIL {CU -}{FE %0 echo2}{CU +}{GE Y N}
- if errorlevel 2 goto end
- erase env.tmp >nul
- :efileOK
- BATUTIL {set cur=}{SA env.tmp}{KI} >nul
- if errorlevel 200 goto envprob
- :frommain
- rem this is for calling main demo file
- set cur=off
- set a=
- set b=
- set c=
- BATUTIL {FP %0 echo3}{GE y n}{EC $_You picked choice $x(RC)$_}{FP %0 echo4}
- BATUTIL {AS}{EC You have $L seconds left (or hit a key)}{GE WA12 EL}{CL}{FP %0 echo5}
- BATUTIL {AS}{QL C -}{FE %0 echo6}
- BATUTIL {AS}{CL}{EC $_$_Input a string$S}{set foo=$Q}{RO -1}{EOL +}{set foo1=$F}{FE %0 echo7}
- BATUTIL {GE WA5 EL}{set cur=}{EC $_}
- if x%1==xfrommain goto end
- BATUTIL {LO env.tmp} >nul
- erase env.tmp >nul
- goto end
- :envprob
- cls
- Echo Problem setting up environment for this demo. Sorry.
- :end
-
-